﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Automation;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace QuickUIT.Tests
{
    [TestClass]
    public class AutomationElementRegexSearchConditionTests
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowExceptionOnNullProperty()
        {
            var regexSearchCondition = new AutomationElementRegexSearchCondition(null, new Regex("Test*"));
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowExceptionOnNullRegex()
        {
            var regexSearchCondition = new AutomationElementRegexSearchCondition(AutomationElement.NameProperty, null);
        }

        [TestMethod]
        public void ShouldGetToStringProperty()
        {
            var regexSearchCondition = new AutomationElementRegexSearchCondition(AutomationElement.NameProperty, new Regex("Test*"));
            Assert.AreEqual("Name=/Test*/", regexSearchCondition.ToString());

            var regexSearchCondition2 = new AutomationElementRegexSearchCondition(AutomationElement.NameProperty, new Regex(@"Test [\d]*"));
            Assert.AreEqual(@"Name=/Test [\d]*/", regexSearchCondition2.ToString());
        }
    }
}
